package algorithmTopics.array;

public class test2 {
    public static void main(String[] args) {
        test2 test2 = new test2();

        int i = test2.maxProfit(new int[]{1, 2, 3, 4, 5});
        System.out.println(i);

    }

    public int maxProfit(int[] prices) {
        int ans = 0;
        for(int i = 0 ;i < prices.length - 1;i++){
            if (prices[i] < prices[i+1]) {
                ans += prices[i + 1] - prices[i];

            }

        }
        return ans;
    }
}
